package com.jdf.org.service.impl;

import com.jdf.basic.util.PageList;
import com.jdf.org.domain.Department;
import com.jdf.org.domain.Employee;
import com.jdf.org.mapper.EmpMapper;
import com.jdf.org.query.EmployeeQuery;
import com.jdf.org.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class EmployeeServiceImpl implements EmployeeService {
    @Autowired
    private EmpMapper empMapper;

    @Override
    @Transactional
    public void save(Employee employee) {
        empMapper.save(employee);
    }

    @Override
    @Transactional
    public void remove(Long id) {
        empMapper.remove(id);
    }

    @Override
    @Transactional
    public void update(Employee employee) {
        empMapper.update(employee);
    }

    @Override
    public Employee load(Long id) {
        return empMapper.load(id);
    }

    @Override
    public List<Employee> loadAll() {
        return empMapper.loadAll();
    }


    @Override
    public PageList<Employee> queryData(EmployeeQuery query) {
        Long aLong = empMapper.queryCount(query);
        if (aLong<1){
            return new PageList<>();
        }
        List<Employee> list = empMapper.queryData(query);
        return new PageList<>(aLong,list);
    }

    @Override
    public void pathDelte(List<Long> ids) {
        empMapper.pathDelte(ids);
    }


}
